#pragma once

#include <src/miscellaneous/stat/Analyzer_Performance.h>
#include <src/math/functor/GaussianFunctor.h>

template<class data1, class data2, std::size_t Dim = data1::Dim>
struct data_Performance_Analyzer {
	void operator()() {
		OS_STATIC_CHECK(data1::Dim == data2::Dim);
		OS_STATIC_CHECK(false); // implement this test
	};
};

template<class data1, class data2>
struct data_Performance_Analyzer<data1,data2,2>
{
	void operator()() {
#if !defined(_DEBUG) // no sense in debug mode and very very slow
		OS_STATIC_CHECK(data1::Dim == 2);
		OS_STATIC_CHECK(data2::Dim == 2);
		std::cout << std::endl << "----data_Performance_Analyzer---------------------" << std::endl ;
		std::cout << std::endl << "----comparaison between" << data1::get_name() <<"  and "<<data2::get_name() <<" ---------------------" << std::endl ;


		data1 test1 = InverseCumulativeFunctor<data1>()(1000,2);

		data2 test2 = InverseCumulativeFunctor<data2>()(1000,2);

		std::cout << std::endl << "----starting comparaison performance test------------" << std::endl ;
		{
			Analyzer_Timer total_time("Elapsed time");
			total_time.clear();
			std::cout << std::endl << "----compare performance constructor------------" << std::endl ;

			{
				Analyzer_Timer begin_loop("begin loop construction");
				{
					Analyzer_Timer timer("loop copy ctor 1");
					for (OS_size i = 0; i < 10000; ++i) {
						if (i % 1000 == 0) std::cout << i;
						data1 a(test1);
					};
				};
				{
					Analyzer_Timer timer("loop copy ctor 2");
					for (OS_size i = 0; i < 10000; ++i) {
						if (i % 1000 == 0) std::cout << i;
						data2 a(test2);
					};
				};
			};
			std::cout << std::endl << "----compare performance algebraic computations--------" << std::endl ;
			{
				Analyzer_Timer begin_loop("begin loop algebraic computation");
				{
					Analyzer_Timer timer("loop computation 1 : a + 3a");
					for (OS_size i = 0; i < 10000; ++i) {
						if (i % 1000 == 0) std::cout << i;
							data1 a = test1 + 3.*test1;
					};
				};
				{
					Analyzer_Timer timer("loop computation 2 : a + 3a");
					for (OS_size i = 0; i < 10000; ++i) {
						if (i % 1000 == 0) std::cout << i;
						data2 a = test2 + 3.*test2;
					};
				};
			};
			total_time.end();
			std::cout << total_time;
			total_time.clear();
		};
		std::cout << std::endl << "----ended. hit a key to finish--------" << std::endl ;
		std::string null;
		std::cin >> null;
#endif
	};
};

void data_Performance_test();

